﻿<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="zh-CN"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="zh-CN"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="zh-CN"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="zh-CN">
<!--<![endif]-->
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录 - YouMd Blog</title>
    <link href="{{ config.static_url }}/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
	<script src="{{ config.static_url }}/js/jquery.js"></script>
    <script src="{{ config.static_url }}/bootstrap/js/bootstrap.min.js"></script>
    <style type="text/css">
			* {
				margin:0;
				padding: 0;
			}
			.loginBox {
				width:420px;
				height:280px;
				padding:0 20px;
				border:1px solid #fff;
				color:#000;
				margin-top:40px;
				border-radius:8px;
				background: white;
				box-shadow:0 0 15px #222;
				background: -moz-linear-gradient(top, #fff, #efefef 8%);
				background: -webkit-gradient(linear, 0 0, 0 100%, from(#f6f6f6), to(#f4f4f4));
				font:11px/1.5em 'Microsoft YaHei' ;
				position: absolute;
				left:50%;
				top:50%;
				margin-left:-210px;
				margin-top:-165px;
			}
			.loginBox h2 {
				height:45px;
				font-size:20px;
				font-weight:normal;
			}
			.loginBox .left {
				border-right:1px solid #ccc;
				height:100%;
				padding-right: 20px;
			}
			.regBtn {
				margin-top:21px;
			}
    </style>
    
 </head> 
 <body> 
<div class="container">
  <div class="loginBox row">
  		<h2 class="text-center">管理登录</h2>
		<form id="manager_login" name="manager_login" action="" method="post" class="form-horizontal">
		  <div class="form-group has-success">
		    <label for="nick_name" class="col-sm-2 col-md-2 control-label">用户名</label>
		    <div class="col-sm-10 col-md-10">
		      <input type="text" class="form-control" id="username" name="username" placeholder="用户名" value="">
		    </div>
		  </div>
		  <div class="form-group has-success">
		    <label for="user_password" class="col-sm-2 col-md-2 control-label">密码</label>
		    <div class="col-sm-10 col-md-10">
		      <input type="password" class="form-control" id="password" name="password" placeholder="密码">
		    </div>
		  </div>
	  	  <div class="form-group">
	  	  	<div class="col-sm-offset-4 col-sm-10" style="color: #990033;"></div>
		  </div>
		  <div class="form-group">
		    <div class="col-sm-offset-4 col-sm-10 col-md-10">
		      	<button class="btn btn-info" data-loading-text="正在登录..." type="submit" onclick="chk();return false">登 录</button>
		      	    <button class="btn btn-info" type="reset">清 空</button>
		    </div>
		  </div>
  		</form>
	</div>
</div>

  <script language="JavaScript">
  			document.getElementById('username').focus()
			function getQueryString(name){
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
				var r = decodeURI(window.location.search).substr(1).match(reg);
				if (r != null) 
					return unescape(r[2]);
				return null;
			}
			
			
            function chk(){
				var uname = $.trim($("#username").val());
				var pwd = $.trim($("#password").val());
				
				if (uname == "" || pwd == "") {
					alert("用户名或密码不能为空!");
					return;
				}
				
				serialize_form = $("#manager_login").serialize();
				$.ajax({
					url: "/auth/login",
					type: "POST",
					data: serialize_form,
					success: function(data){
						if (data.code ==0) {
							var m_next = getQueryString('next');
							var m_pop = getQueryString('pop');
							if (m_next) {
								window.location.href = m_next;
							}else if(m_pop){
								window.close();
							}
							else {
								window.location.href = "/";
							}
						}
						else {
							$("#password").val('').focus();
							alert("用户名或密码不正确!");
						}
					}
				});
			}
		</script>  
 </body>
</html>